#!/usr/bin/env python
# encoding: utf-8
'''
@author: Excelsiorly
@license: (C) Copyright 2021, All Rights Reserved.
@contact: excelsiorly@qq.com
@file: 0021.py
@time: 2021/9/16 14:34
@desc: https://leetcode-cn.com/problems/ba-shu-zi-fan-yi-cheng-zi-fu-chuan-lcof
'''
class Solution:
    def translateNum(self, num: int) -> int:
        s = str(num)
        n = len(s)
        if n==1 or n==0:
            return 1
        dp = [0]*n
        dp[0] = 1
        if int(s[0]+s[1])<=25:
            dp[1] = 2
        else:
            dp[1] = 1
        for i in range(2, n):
            temp = s[i-1] + s[i]
            if 10<=int(temp)<=25:
                dp[i] = (dp[i-2]) +  dp[i-1]
            else:
                dp[i] = dp[i-1]

        return dp[-1]

if __name__ == '__main__':
    sl = Solution()
    num = 506
    res = sl.translateNum(num)
    print(res)